package cn.iocoder.yudao.module.book.controller.app;

import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.book.controller.app.vo.AppAllUsersRecentCheckInRecordsRespVO;
import cn.iocoder.yudao.module.book.controller.app.vo.AppBookCheckInRecordSaveReqVO;
import cn.iocoder.yudao.module.book.controller.app.vo.AppBookCheckInRecordSaveRespVO;
import cn.iocoder.yudao.module.book.controller.app.vo.AppCheckInCalendarDataRespVO;
import cn.iocoder.yudao.module.book.service.app.AppBookCheckInRecordService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/bookCheckInRecord")
public class AppBookCheckInRecordController {

    @Resource
    private AppBookCheckInRecordService bookCheckInRecordService;

    @PostMapping("/createBookCheckInRecord")
    @Operation(summary = "打卡")
    public CommonResult<Long> createBookCheckInRecord(@Validated @RequestBody AppBookCheckInRecordSaveReqVO bookCheckInRecordSaveReqVO) {
        return CommonResult.success(bookCheckInRecordService.createBookCheckInRecord(bookCheckInRecordSaveReqVO));
    }

    @GetMapping("/getBookCheckInRecordById")
    @Operation(summary = "查询打卡详情")
    public CommonResult<AppBookCheckInRecordSaveRespVO> getBookCheckInRecordById() {
        return CommonResult.success(bookCheckInRecordService.getBookCheckInRecordById());
    }

    @GetMapping("/checkInValidation")
    @Operation(summary = "打卡校验")
    public CommonResult<Boolean> checkInValidation() {
        return CommonResult.success(bookCheckInRecordService.checkInValidation());
    }

    @GetMapping("/getCheckInCalendarData")
    @Operation(summary = "获取打卡日历数据")
    public CommonResult<AppCheckInCalendarDataRespVO> getCheckInCalendarData() {
        return CommonResult.success(bookCheckInRecordService.getCheckInCalendarData());
    }

    @GetMapping("/allUsersRecentCheckInRecords")
    @Operation(summary = "按照标签获取最近打卡记录")
    public CommonResult<List<AppAllUsersRecentCheckInRecordsRespVO>> allUsersRecentCheckInRecords(@RequestParam String currentTab) {
        log.info(currentTab);
        return CommonResult.success(bookCheckInRecordService.allUsersRecentCheckInRecords(currentTab));
    }

}